<%@page import="java.math.BigDecimal"%>
<%@page import="org.springframework.security.core.context.SecurityContextHolder"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="org.apache.commons.lang.time.DateFormatUtils"%>
<%@page import="org.springframework.util.CollectionUtils"%>
<%@page import="java.util.Collection"%>
<%@ include file="../common/common_include.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	LeaveForm form = (LeaveForm)request.getAttribute("command");
	TsUser user = (TsUser)request.getAttribute("user");
	List<BigDecimal> userRoleList = new ArrayList<BigDecimal>();
	if(null!=user){
		if(StringUtils.isNotBlank(user.getRoleIds())){
			String roleArr[] = user.getRoleIds().split(",");
			for(String r:roleArr){
				userRoleList.add(new BigDecimal(r));
			}
		}
	}
	List<TblOaAuthRole> roleList = (List<TblOaAuthRole> )request.getAttribute("roleList");
%>

<style>
	.selectHour-split{
		padding:0 2px;
		margin-right:5px;	
	}
	.selectMinute-split{
		padding:0 2px;
	}
</style>

<div>
	<form id="LeaveAddForm" target="_coreIframe" method="post" action="<%=request.getContextPath()%>/check/doEditUser" enctype="multipart/form-data">
		<div class="breadcrumb">
			<div class="bcIcon"></div>
			<ul class="bcNav">
				<li>修改角色</li>
			</ul>
		</div>
		<table class="formTable">
			<input type="hidden" name="userid" value="<%=user.getUserid()%>">
			<input type="hidden" name="username" value="<%=user.getUsername()%>">
			<tr>
				<td class="tdTitle">用户ID:</td>
				<td><input class="inputText xs" value="<%=user.getUserid()%>"  disabled="disabled"></td>
			</tr>
			<tr>
				<td class="tdTitle">用户姓名:</td>
				<td><input class="inputText xs" type="text" checkNull="true" value="<%=user.getUsername()%>" disabled="disabled"/></td>
			</tr>
			<tr>
				<td class="tdTitle">角色：</td>
				<td class="" colspan="2">
					<div style="padding-top:10px;padding-bottom:10px;">
						<div class="checkbox-wrap">
						<%
							if(!CollectionUtils.isEmpty(roleList)){
								for(TblOaAuthRole role:roleList){
									%>
									<div class="checkbox-wrap">
										<label>
											<input type="checkbox" 
											data-value="1" 
											value="<%=EncrypTool.encode(role.getRoleId()+"")%>" 
											name="roles" 
											class="checkbox" 
											<%=userRoleList.contains(role.getRoleId())?"checked='checked'":""%>
											 >
											<span><%=role.getRoleDesc() %></span>
										</label>
									</div>
									<%
								}
							}
						%>
						</div>
					</div>
				</td>
			</tr>
			<tr>
				<td class="tdTitle"></td>
				<td>
					<div>
						<input class="input-btn-microsoft" type="submit" value="提交">
						<a class="a-btn-microsoft" href="javascript:XF.Check.userList()">取消</a>
					</div>
				</td>
			</tr>	
		</table>
	</form>
	<iframe id="_coreIframe" name="_coreIframe" style="display: none;"></iframe>
</div>
<script>
XF.Check.init();
XF.Setting.initAddRole();
</script>


